package com.service.statistics.scheduling;

import com.service.statistics.service.DailyService;
import com.service.statistics.utils.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class StatisticsDailyScheduling {

    @Autowired
    private DailyService dailyService;

    /**
     * 每晚12点 将前一天的数据添加到数据库中
     */
    @Scheduled(cron = "0 0 0,1 * * ?")
    public void createStatisticsDaily(){
        dailyService.StatisticsDailyCount(DateUtil.formatDate(DateUtil.addDays(new Date(), -1)));
    }

}
